(function () {
  var ctrls = angular.module(MyAppConfig.controllers);
  ctrls.controller('logsManageCtrl', ['$scope', '$log', 'DialogService', 'DataService', logsManageCtrl]);

  function logsManageCtrl($scope, $log, DialogService, DataService) {
    $log.debug('logsManageCtrl init...');

    // 处理scope销毁
    $scope.$on('$destroy', function () {
      $log.debug('logsManageCtrl destroy...');
    });

    $scope.page = {
      pageNumber: 1,
      pageSize: 5
    };

    $scope.queryLog = function () {
      DialogService.showWait('log查询中...');
      DataService.send('/logs/queryAll', {
        page: $scope.page
      }, function (data) {
        DialogService.hideWait();
        if (data.success) {
          $scope.list = data.datas.list;
          $scope.page = data.datas.page;
          return;
        }
        DialogService.showAlert(data.message);
      });

    };
    $scope.queryLog();

    $scope.toPage = function (pn) {

      if (pn <= 0 || pn > $scope.page.pageCount || pn == $scope.page.pageNumber) {
        return;
      }
      //分页查询
      $scope.page.pageNumber = pn;
      $scope.queryLog();
    };
  }
})();